﻿using System;
using System.Windows.Markup;

namespace Informant.UI.Wpf.MarkupExtensions
{
	[MarkupExtensionReturnType(typeof(object[]))]
	public class EnumValuesExtension : MarkupExtension
	{
		public EnumValuesExtension()
		{
		}

		public EnumValuesExtension(Type enumType)
		{
			this.EnumType = enumType;
		}

		[ConstructorArgument("enumType")]
		public Type EnumType { get; set; }

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			if (this.EnumType == null)
				throw new ArgumentException("The enum type is not set");
			//Return custom Values for an enum here instead of Enum.GetValues()
			return Enum.GetValues(this.EnumType);
		}
	}
}
